
const express=require('express');
const app=express();
const router = express.Router();
const jwt= require('./utils/jwt')
const path=require('path');  //为解决不同系统路径/
app.use(express.static(path.join(__dirname,'..','public'))) //关联静态文件
//app.use(express.static(path.join(__dirname,'..','dist'))) //关联静态文件
//解决跨域
app.use('*',function(req,res,next){
    res.header("X-Powered-By",' 3.2.1')
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Content-Type", "application/json;charset=utf-8");
    res.header("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
    next()
});

const bodyParser=require('body-parser')
app.use(bodyParser.json())
// app.use(bodyParser.json({limit: '2100000kb'})); 
// app.use(bodyParser.urlencoded({limit: '2100000kb', extended: true })); 



//
// const mv = function(req,res,next){
//     console.log('中间件函数');
//     next();
// };
//
//
//
// // 路由级中间件
// router.use((req, res, next) => {
//     console.log('路由级中间件');
//     next();
// });
// app.use(function (req,res,next){
//     console.log('调用了第1个全局中间件',req.method);
//     if(req.method!=='OPTIONS'){
//         jwt.auth(req,res,next);
//     }
// })
const user = require('./user/user.js');
const card = require('./card/index.js');
const menu = require('./menu/index.js');
const role = require('./role/index.js');
const meeting = require('./meeting/index.js');

app.use('/user',user);
app.use('/card',card);
app.use('/menu',menu);
app.use('/role',role);
app.use('/meeting',meeting);

app.listen(3000,function (err) {
    if(err){
        console.log(err)
    }
    console.log("启动成功 port 3000")
})
